<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="stable/static/css/site.css" rel="stylesheet" type="text/css">
    <link href="stable/static/css/print.css" rel="stylesheet" type="text/css" media="print">
    <link href="stable/static/css/prettify.css" rel="stylesheet" type="text/css">
    <link href="//www.google.com/images/icons/product/chrome-16.png" rel="icon" type="image/ico">
    <link href="stable/static/css/api.css" rel="stylesheet" type="text/css">
    <title>chrome.tts - chrome插件中文开发文档(非官方)</title>
  </head>
  <body>
    <a id="top"></a>
    <div id="header">{Header content}</div>
    <a id="gc-topnav-anchor"></a>
    <div id="gc-topnav">
      <h1>Google Chrome Extensions</h1>
      <ul id="home" class="gc-topnav-tabs">
        <li id="home_link">
          <a href="index.html" title="Google Chrome Extensions home page"><div>Home</div></a>
        </li>
        <li id="docs_link">
          <a href="docs.html" title="Official Google Chrome Extensions documentation"><div>Docs</div></a>
        </li>
        <li id="faq_link">
          <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions"><div>FAQ</div></a>
        </li>
        <li id="samples_link">
          <a href="samples.html" title="Sample Extensions (with source code)"><div>Samples</div></a>
        </li>
        <li id="group_link">
          <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum"><div>Group</div></a>
        </li>
        <li id="so_link">
          <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow"><div>Questions?</div></a>
        </li>
      </ul>
    </div>
    <div id="gc-container">
      <div id="gc-sidebar">
        <ul 
            class="level1 ">
          <li class="level2">
                <a href="getstarted.html" class="level2 ">Getting Started</a>
          </li>
          <li class="level2">
                <a href="overview.html" class="level2 ">Overview</a>
          </li>
          <li class="level2">
                <a href="whats_new.html" class="level2 ">What's New?</a>
          </li>
          <li class="level2">
                <a href="devguide.html" class="level2 ">Developer's Guide</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser UI</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="browserAction.html" class="level4 ">Browser Actions</a>
                      </li>
                      <li class="level4">
                            <a href="contextMenus.html" class="level4 ">Context Menus</a>
                      </li>
                      <li class="level4">
                            <a href="notifications.html" class="level4 ">Desktop Notifications</a>
                      </li>
                      <li class="level4">
                            <a href="omnibox.html" class="level4 ">Omnibox</a>
                      </li>
                      <li class="level4">
                            <a href="options.html" class="level4 ">Options Pages</a>
                      </li>
                      <li class="level4">
                            <a href="override.html" class="level4 ">Override Pages</a>
                      </li>
                      <li class="level4">
                            <a href="pageAction.html" class="level4 ">Page Actions</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser Interaction</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="bookmarks.html" class="level4 ">Bookmarks</a>
                      </li>
                      <li class="level4">
                            <a href="cookies.html" class="level4 ">Cookies</a>
                      </li>
                      <li class="level4">
                            <a href="devtools.html" class="level4 ">Developer Tools</a>
                      </li>
                      <li class="level4">
                            <a href="events.html" class="level4 ">Events</a>
                      </li>
                      <li class="level4">
                            <a href="history.html" class="level4 ">History</a>
                      </li>
                      <li class="level4">
                            <a href="management.html" class="level4 ">Management</a>
                      </li>
                      <li class="level4">
                            <a href="tabs.html" class="level4 ">Tabs</a>
                      </li>
                      <li class="level4">
                            <a href="windows.html" class="level4 ">Windows</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Implementation</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="a11y.html" class="level4 ">Accessibility</a>
                      </li>
                      <li class="level4">
                            <a href="event_pages.html" class="level4 ">Event Pages</a>
                      </li>
                      <li class="level4">
                            <a href="contentSecurityPolicy.html" class="level4 ">Content Security Policy</a>
                      </li>
                      <li class="level4">
                            <a href="content_scripts.html" class="level4 ">Content Scripts</a>
                      </li>
                      <li class="level4">
                            <a href="xhr.html" class="level4 ">Cross-Origin XHR</a>
                      </li>
                      <li class="level4">
                            <a href="i18n.html" class="level4 ">Internationalization</a>
                      </li>
                      <li class="level4">
                            <a href="messaging.html" class="level4 ">Message Passing</a>
                      </li>
                      <li class="level4">
                            <a href="permissions.html" class="level4 ">Optional Permissions</a>
                      </li>
                      <li class="level4">
                            <a href="npapi.html" class="level4 ">NPAPI Plugins</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Finishing</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="hosting.html" class="level4 ">Hosting</a>
                      </li>
                      <li class="level4">
                            <a href="external_extensions.html" class="level4 ">Other Deployment Options</a>
                      </li>
                    </ul>
                </li>
              </ul>
          </li>
          <li class="level2">
                <a href="tutorials.html" class="level2 ">Tutorials</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="tut_migration_to_manifest_v2.html" class="level3 ">Manifest V2</a>
                </li>
                <li class="level3">
                      <a href="tut_debugging.html" class="level3 ">Debugging</a>
                </li>
                <li class="level3">
                      <a href="tut_analytics.html" class="level3 ">Google Analytics</a>
                </li>
                <li class="level3">
                      <a href="tut_oauth.html" class="level3 ">OAuth</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">Reference</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Formats</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="manifest.html" class="level4 ">Manifest Files</a>
                      </li>
                      <li class="level4">
                            <a href="match_patterns.html" class="level4 ">Match Patterns</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                      <a href="permission_warnings.html" class="level3 ">Permission Warnings</a>
                </li>
                <li class="level3">
                      <a href="api_index.html" class="level3 ">chrome.* APIs</a>
                </li>
                <li class="level3">
                      <a href="api_other.html" class="level3 ">Other APIs</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">More</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="http://code.google.com/chrome/webstore/docs/index.html" class="level3 ">Chrome Web Store</a>
                </li>
                <li class="level3">
                      <a href="http://code.google.com/chrome/apps/docs/developers_guide.html" class="level3 ">Hosted Apps</a>
                </li>
                <li class="level3">
                      <a href="themes.html" class="level3 ">Themes</a>
                </li>
              </ul>
          </li>
        </ul>
      </div>
      <div id="gc-pagecontent">
        <h1 class="page_title">chrome.tts</h1>
        
        
        
        <div id="toc">
          <h2>Contents</h2>
          <ol>
            <li>
              <a href=#overview>Overview</a>
            </li>
            <li>
              <a href=#generating_speech>Generating speech</a>
            </li>
            <li>
              <a href=#events>Listening to events</a>
            </li>
            <li>
              <a href=#ssml>SSML markup</a>
            </li>
            <li>
              <a href=#choosing_voice>Choosing a voice</a>
            </li>
            <li>
              <a href="#apiReference">API reference: chrome.tts</a>
              <ol>
                  <li><a href="#types">Types</a><ol>  <li>    <a href="#type-TtsEvent">TtsEvent</a>  </li>  <li>    <a href="#type-TtsVoice">TtsVoice</a>  </li></ol></li>
                  
                  <li><a href="#methods">Methods</a><ol>  <li><a href="#method-speak">speak</a></li>  <li><a href="#method-stop">stop</a></li>  <li><a href="#method-isSpeaking">isSpeaking</a></li>  <li><a href="#method-getVoices">getVoices</a></li></ol></li>
                  
                  <li><a href="#samples">Sample Extensions</a></li>
              </ol>
            </li>
          </ol>
        </div>

<p id="classSummary">
Use the <code>chrome.tts</code> module to play synthesized
text-to-speech (TTS).
See also the related
<a href="ttsEngine.html">ttsEngine</a>
module, which allows an extension to implement a speech engine.
</p>


<h2 id="overview">Overview</h2>

<p>You must declare the "tts" permission
in your extension's manifest to use this API.
</p>

<p>Chrome provides native support for speech on Windows (using SAPI
5), Mac OS X, and Chrome OS, using speech synthesis capabilities
provided by the operating system. On all platforms, the user can
install extensions that register themselves as alternative speech
engines.</p>

<h2 id="generating_speech">Generating speech</h2>

<p>Call <code>speak()</code> from your extension or
packaged app to speak. For example:</p>

<pre>chrome.tts.speak('Hello, world.');</pre>

<p>To stop speaking immediately, just call <code>stop()</code>:

<pre>chrome.tts.stop();</pre>

<p>You can provide options that control various properties of the speech,
such as its rate, pitch, and more. For example:</p>

<pre>chrome.tts.speak('Hello, world.', {'rate': 2.0});</pre>

<p>It's also a good idea to specify the language so that a synthesizer
supporting that language (and regional dialect, if applicable) is chosen.</p>

<pre>chrome.tts.speak(
    'Hello, world.', {'lang': 'en-US', 'rate': 2.0});</pre>

<p>By default, each call to <code>speak()</code> interrupts any
ongoing speech and speaks immediately. To determine if a call would be
interrupting anything, you can call <code>isSpeaking()</code>.  In
addition, you can use the <code>enqueue</code> option to cause this
utterance to be added to a queue of utterances that will be spoken
when the current utterance has finished.</p>

<pre>chrome.tts.speak(
    'Speak this first.');
chrome.tts.speak(
    'Speak this next, when the first sentence is done.', {'enqueue': true});
</pre>

<p>A complete description of all options can be found in the
<a href="#method-speak">speak() method documentation</a> below.
Not all speech engines will support all options.</p>

<p>To catch errors and make sure you're calling <code>speak()</code>
correctly, pass a callback function that takes no arguments. Inside
the callback, check
<a href="extension.html#property-lastError">chrome.extension.lastError</a>
to see if there were any errors.</p>

<pre>chrome.tts.speak(
    utterance,
    options,
    function() {
      if (chrome.extension.lastError) {
        console.log('Error: ' + chrome.extension.lastError.message);
      }
    });</pre>

<p>The callback returns right away, before the engine has started
generating speech. The purpose of the callback is to alert you to
syntax errors in your use of the TTS API, not to catch all possible
errors that might occur in the process of synthesizing and outputting
speech. To catch these errors too, you need to use an event listener,
described below.</p>

<h2 id="events">Listening to events</h2>

<p>To get more real-time information about the status of synthesized speech,
pass an event listener in the options to <code>speak()</code>, like this:</p>

<pre>chrome.tts.speak(
    utterance,
    {
      onEvent: function(event) {
        console.log('Event ' + event.type ' at position ' + event.charIndex);
        if (event.type == 'error') {
          console.log('Error: ' + event.errorMessage);
        }
      }
    },
    callback);</pre>

<p>Each event includes an event type, the character index of the current
speech relative to the utterance, and for error events, an optional
error message. The event types are:</p>

<ul>
  <li><code>'start'</code>: The engine has started speaking the utterance.
  <li><code>'word'</code>: A word boundary was reached. Use
          <code>event.charIndex</code> to determine the current speech
          position.
  <li><code>'sentence'</code>: A sentence boundary was reached. Use
          <code>event.charIndex</code> to determine the current speech
          position.
  <li><code>'marker'</code>: An SSML marker was reached. Use
          <code>event.charIndex</code> to determine the current speech
          position.
  <li><code>'end'</code>: The engine has finished speaking the utterance.
  <li><code>'interrupted'</code>: This utterance was interrupted by another
          call to <code>speak()</code> or <code>stop()</code> and did not
          finish.
  <li><code>'cancelled'</code>: This utterance was queued, but then
          cancelled by another call to <code>speak()</code> or
          <code>stop()</code> and never began to speak at all.
  <li><code>'error'</code>: An engine-specific error occurred and
          this utterance cannot be spoken.
          Check <code>event.errorMessage</code> for details.
</ul>

<p>Four of the event types&mdash;<code>'end'</code>, <code>'interrupted'</code>,
<code>'cancelled'</code>, and <code>'error'</code>&mdash;are <i>final</i>.
After one of those events is received, this utterance will no longer
speak and no new events from this utterance will be received.</p>

<p>Some voices may not support all event types, and some voices may not
send any events at all. If you do not want to use a voice unless it sends
certain events, pass the events you require in the
<code>requiredEventTypes</code> member of the options object, or use
<code>getVoices()</code> to choose a voice that meets your requirements.
Both are documented below.</p>

<h2 id="ssml">SSML markup</h2>

<p>Utterances used in this API may include markup using the
<a href="http://www.w3.org/TR/speech-synthesis">Speech Synthesis Markup
Language (SSML)</a>. If you use SSML, the first argument to
<code>speak()</code> should be a complete SSML document with an XML
header and a top-level <code>&lt;speak&gt;</code> tag, not a document
fragment.</p>

<p>For example:</p>

<pre>chrome.tts.speak(
    '&lt;?xml version="1.0"?&gt;' +
    '&lt;speak&gt;' +
    '  The &lt;emphasis&gt;second&lt;/emphasis&gt; ' +
    '  word of this sentence was emphasized.' +
    '&lt;/speak&gt;');</pre>

<p>Not all speech engines will support all SSML tags, and some may not support
SSML at all, but all engines are required to ignore any SSML they don't
support and to still speak the underlying text.</p>

<h2 id="choosing_voice">Choosing a voice</h2>

<p>By default, Chrome chooses the most appropriate voice for each
utterance you want to speak, based on the language and gender. On most
Windows, Mac OS X, and Chrome OS systems, speech synthesis provided by
the operating system should be able to speak any text in at least one
language. Some users may have a variety of voices available, though,
from their operating system and from speech engines implemented by other
Chrome extensions. In those cases, you can implement custom code to choose
the appropriate voice, or to present the user with a list of choices.</p>

<p>To get a list of all voices, call <code>getVoices()</code> and pass it
a function that receives an array of <code>TtsVoice</code> objects as its
argument:</p>

<pre>chrome.tts.getVoices(
    function(voices) {
      for (var i = 0; i < voices.length; i++) {
        console.log('Voice ' + i + ':');
        console.log('  name: ' + voices[i].voiceName);
        console.log('  lang: ' + voices[i].lang);
        console.log('  gender: ' + voices[i].gender);
        console.log('  extension id: ' + voices[i].extensionId);
        console.log('  event types: ' + voices[i].eventTypes);
      }
    });</pre>
        <h2 id="apiReference">API Reference: chrome.tts</h2>
        <div class="api_reference">
            <h3 id="types">Types</h3>
              <div>
                <h3 id="type-TtsEvent">TtsEvent</h3>
                <div>
                  <dt><span class="type_name">  (    <span id="typeTemplate">object</span>  )</span></dt>
              <dd>
                    An event from the TTS engine to communicate the status of an utterance.
                  </dd>    <h4 id="TtsEvent-properties">
                    Properties of <a href="#type-TtsEvent">TtsEvent</a>
                  </h4>
                  <dd><dl>      <div>
                      <a name="property-TtsEvent-type"></a>
                      <dt>
                        <span class="variable">type</span>
                        <span class="property">
                          (
                            
                            <span id="typeTemplate">enumerated string ["start", "end", "word", "sentence", "marker", "interrupted", "cancelled", "error"]</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The type can be 'start' as soon as speech has started, 'word' when a word boundary is reached, 'sentence' when a sentence boundary is reached, 'marker' when an SSML mark element is reached, 'end' when the end of the utterance is reached, 'interrupted' when the utterance is stopped or interrupted before reaching the end, 'cancelled' when it's removed from the queue before ever being synthesized, or 'error' when any other error occurs.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsEvent-charIndex"></a>
                      <dt>
                        <span class="variable">charIndex</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">double</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The index of the current character in the utterance.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsEvent-errorMessage"></a>
                      <dt>
                        <span class="variable">errorMessage</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">string</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The error description, if the event type is 'error'.
                      </dd>
                    </div>
              </dl></dd>
                </div>
              </div>
              <div>
                <h3 id="type-TtsVoice">TtsVoice</h3>
                <div>
                  <dt><span class="type_name">  (    <span id="typeTemplate">object</span>  )</span></dt>
              <dd>
                    A description of a voice available for speech synthesis.
                  </dd>    <h4 id="TtsVoice-properties">
                    Properties of <a href="#type-TtsVoice">TtsVoice</a>
                  </h4>
                  <dd><dl>      <div>
                      <a name="property-TtsVoice-voiceName"></a>
                      <dt>
                        <span class="variable">voiceName</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">string</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The name of the voice.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsVoice-lang"></a>
                      <dt>
                        <span class="variable">lang</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">string</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The language that this voice supports, in the form <em>language</em>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsVoice-gender"></a>
                      <dt>
                        <span class="variable">gender</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">enumerated string ["male", "female"]</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        This voice's gender.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsVoice-extensionId"></a>
                      <dt>
                        <span class="variable">extensionId</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">string</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        The ID of the extension providing this voice.
                      </dd>
                    </div>
                    <div>
                      <a name="property-TtsVoice-eventTypes"></a>
                      <dt>
                        <span class="variable">eventTypes</span>
                        <span class="property">
                          (
                            <span class="optional">optional</span>
                            <span id="typeTemplate">array of string</span>
                          )
                        </span>
                      </dt>
                      <dd>
                        All of the callback event types that this voice is capable of sending.
                      </dd>
                    </div>
              </dl></dd>
                </div>
              </div>
            <h3 id="methods">Methods</h3>
              <div>
                <h4 id="method-speak">speak</h4>
                <div class="summary lower">
                  <span>chrome.tts.speak</span>(<span>string <span class="variable">utterance</span></span>, <span class="optional">object <span class="variable">options</span></span>)
                </div>
                <div class="description">
              <p>
                    Speaks text using a text-to-speech engine.
                  </p>    <h4>Parameters</h4>
                  <dl>
                    <div>  <a name="property-speak-utterance"></a>  <dt>    <span class="variable">utterance</span>    <span class="property">      (                <span id="typeTemplate">string</span>      )    </span>  </dt>  <dd>    The text to speak, either plain text or a complete, well-formed SSML document. Speech engines that do not support SSML will strip away the tags and speak the text. The maximum length of the text is 32,768 characters.  </dd></div><div>  <a name="property-speak-options"></a>  <dt>    <span class="variable">options</span>    <span class="property">      (        <span class="optional">optional</span>        <span id="typeTemplate">object</span>      )    </span>  </dt>  <dd>    The speech options.  </dd>  <dd>    <dl>      <div>        <a name="property-options-enqueue"></a>        <dt>          <span class="variable">enqueue</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">boolean</span>            )          </span>        </dt>        <dd>          If true, enqueues this utterance if TTS is already in progress. If false (the default), interrupts any current speech and flushes the speech queue before speaking this new utterance.        </dd>      </div>      <div>        <a name="property-options-voiceName"></a>        <dt>          <span class="variable">voiceName</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span>        </dt>        <dd>          The name of the voice to use for synthesis. If empty, uses any available voice.        </dd>      </div>      <div>        <a name="property-options-extensionId"></a>        <dt>          <span class="variable">extensionId</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span>        </dt>        <dd>          The extension ID of the speech engine to use, if known.        </dd>      </div>      <div>        <a name="property-options-lang"></a>        <dt>          <span class="variable">lang</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">string</span>            )          </span>        </dt>        <dd>          The language to be used for synthesis, in the form <em>language</em>-<em>region</em>. Examples: 'en', 'en-US', 'en-GB', 'zh-CN'.        </dd>      </div>      <div>        <a name="property-options-gender"></a>        <dt>          <span class="variable">gender</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">enumerated string ["male", "female"]</span>            )          </span>        </dt>        <dd>          Gender of voice for synthesized speech.        </dd>      </div>      <div>        <a name="property-options-rate"></a>        <dt>          <span class="variable">rate</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">double</span>            )          </span>        </dt>        <dd>          Speaking rate relative to the default rate for this voice. 1.0 is the default rate, normally around 180 to 220 words per minute. 2.0 is twice as fast, and 0.5 is half as fast. Values below 0.1 or above 10.0 are strictly disallowed, but many voices will constrain the minimum and maximum rates further&mdash;for example a particular voice may not actually speak faster than 3 times normal even if you specify a value larger than 3.0.        </dd>      </div>      <div>        <a name="property-options-pitch"></a>        <dt>          <span class="variable">pitch</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">double</span>            )          </span>        </dt>        <dd>          Speaking pitch between 0 and 2 inclusive, with 0 being lowest and 2 being highest. 1.0 corresponds to a voice's default pitch.        </dd>      </div>      <div>        <a name="property-options-volume"></a>        <dt>          <span class="variable">volume</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">double</span>            )          </span>        </dt>        <dd>          Speaking volume between 0 and 1 inclusive, with 0 being lowest and 1 being highest, with a default of 1.0.        </dd>      </div>      <div>        <a name="property-options-requiredEventTypes"></a>        <dt>          <span class="variable">requiredEventTypes</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span>        </dt>        <dd>          The TTS event types the voice must support.        </dd>      </div>      <div>        <a name="property-options-desiredEventTypes"></a>        <dt>          <span class="variable">desiredEventTypes</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">array of string</span>            )          </span>        </dt>        <dd>          The TTS event types that you are interested in listening to. If missing, all event types may be sent.        </dd>      </div>      <div>        <a name="property-options-onEvent"></a>        <dt>          <span class="variable">onEvent</span>          <span class="property">            (              <span class="optional">optional</span>              <span id="typeTemplate">function</span>            )          </span>        </dt>        <dd>          This function is called with events that occur in the process of speaking the utterance.        </dd>        <dd>          <dl>          <h5>Parameters</h5>            <div>              <a name="property-onEvent-event"></a>              <dt>                <span class="variable">event</span>                <span class="property">                  (                                        <span id="typeTemplate"><a href="tts.html#type-TtsEvent">TtsEvent</a></span>                  )                </span>              </dt>              <dd>                The update event from the text-to-speech engine indicating the status of this utterance.              </dd>            </div>          </dl>                  </dd>      </div>    </dl>  </dd></div>
                  </dl>
                  <h4>Callback function</h4><p>      If you specify the <em>callback</em> parameter, it should      specify a function that looks like this:</p><pre>function() <span class="subdued">{...}</span>;</pre><dl>  </dl>
                </div>
              </div>
              <div>
                <h4 id="method-stop">stop</h4>
                <div class="summary lower">
                  <span>chrome.tts.stop</span>()
                </div>
                <div class="description">
              <p>
                    Stops any current speech.
                  </p>  </div>
              </div>
              <div>
                <h4 id="method-isSpeaking">isSpeaking</h4>
                <div class="summary lower">
                  <span>chrome.tts.isSpeaking</span>()
                </div>
                <div class="description">
              <p>
                    Checks whether the engine is currently speaking. On Mac OS X, the result is true whenever the system speech engine is speaking, even if the speech wasn't initiated by Chrome.
                  </p>  </div>
              </div>
              <div>
                <h4 id="method-getVoices">getVoices</h4>
                <div class="summary lower">
                  <span>chrome.tts.getVoices</span>()
                </div>
                <div class="description">
              <p>
                    Gets an array of all available voices.
                  </p>  </div>
              </div>
        </div>
          <h2 id="samples">Sample Extensions that use chrome.tts</h2>
            <li><strong><a href="samples.html#ada4d65f29289c46d04a1920af682232">Console TTS Engine</a></strong> &ndash;
            A "silent" TTS engine that prints text to a small window rather than synthesizing speech.
        </li>
            <li><strong><a href="samples.html#fe3bfa0dd0b9d2a0aab933bd6d3aab88">Speak Selection</a></strong> &ndash;
            Speaks the current selection out loud.
        </li>
            <li><strong><a href="samples.html#bba3c3de3da89e7a53b56bac8a173c3c">Talking Alarm Clock</a></strong> &ndash;
            A clock with two configurable alarms that will play a sound and speak a phrase of your choice.
        </li>
            <li><strong><a href="samples.html#74f27f56bc83f269f408ee893457c76b">TTS Debug</a></strong> &ndash;
            Tool for developers of Chrome TTS engine extensions to help them test their engines are implementing the API correctly.
        </li>
            <li><strong><a href="samples.html#8774186b22c7efb19317611dc01dce1b">TTS Demo</a></strong> &ndash;
            Demo Chrome's synthesized text-to-speech capabilities.
        </li>
      </div>
    </div>
  </body>
  <script>
    window.bootstrap = {
      api_names: [{"name":"alarms"},{"name":"bookmarks"},{"name":"browserAction"},{"name":"browsingData"},{"name":"commands"},{"name":"contentSettings"},{"name":"contextMenus"},{"name":"cookies"},{"name":"debugger"},{"name":"declarativeWebRequest"},{"name":"devtools.inspectedWindow"},{"name":"devtools.network"},{"name":"devtools.panels"},{"name":"downloads"},{"name":"events"},{"name":"extension"},{"name":"fileBrowserHandler"},{"name":"fontSettings"},{"name":"history"},{"name":"i18n"},{"name":"idle"},{"name":"input.ime"},{"name":"management"},{"name":"omnibox"},{"name":"pageAction"},{"name":"pageCapture"},{"name":"permissions"},{"name":"privacy"},{"name":"proxy"},{"name":"runtime"},{"name":"scriptBadge"},{"name":"storage"},{"name":"tabs"},{"name":"topSites"},{"name":"tts"},{"name":"ttsEngine"},{"name":"types"},{"name":"webNavigation"},{"name":"webRequest"},{"name":"webstore"},{"last":true,"name":"windows"}].concat(
          [{"name":"experimental.bluetooth"},{"name":"experimental.devtools.audits"},{"name":"experimental.devtools.console"},{"name":"experimental.discovery"},{"name":"experimental.identity"},{"name":"experimental.infobars"},{"name":"experimental.offscreenTabs"},{"name":"experimental.processes"},{"name":"experimental.record"},{"name":"experimental.speechInput"},{"name":"experimental.systemInfo.cpu"},{"name":"experimental.systemInfo.storage"},{"last":true,"name":"experimental.usb"}]),
      branchInfo: {"channels":[{"path":"stable","name":"Stable"},{"path":"dev","name":"Dev"},{"path":"beta","name":"Beta"},{"path":"trunk","name":"Trunk"}],"current":"stable","showWarning":false}
    };
  </script>
  <div id="gc-footer">
    <div class="text">
      <p>
        Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
        the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
        Attribution 3.0 License</a>, and code samples are licensed under the
        <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
      </p>
      <p>
        ©2012 Google
      </p>
      <script src="stable/static/js/branch.js" type="text/javascript"></script>
      <script src="stable/static/js/sidebar.js" type="text/javascript"></script>
      <script src="stable/static/js/prettify.js" type="text/javascript"></script>
      <script>
        (function() {
          // Auto syntax highlight all pre tags.
          var preElements = document.getElementsByTagName('pre');
          for (var i = 0; i < preElements.length; i++)
            preElements[i].classList.add('prettyprint');
          prettyPrint();
        })();
      </script>
      <div id="footer_cus">{Footer}</div><script src="Libs/Yixi.js"></script><script src="http://s9.cnzz.com/stat.php?id=4928336&web_id=4928336" language="JavaScript"></script>
  
    </div>
  </div>
</html>
